﻿using System;
using System.Collections.Generic;
using System.Text;
using TileGert;

namespace TestApp.Tests
{
  public class CircleClosestPoint : TestGame
  {
    private GertCircle _circle = null;
    private GertPoint _point = null;
    private GertPoint _closest = null;

    protected override void AfterInit()
    {
      _circle = new GertCircle(400, 300, 200);
      _point = new GertPoint(100, 300);
    }

    protected override void Update(float timestep)
    {
      int step = 100;
      Input.Update();
      if (Input.Keyboard.KeyIsPressed(GertKeys.LeftArrow))
        _point.X -= step * timestep;
      if (Input.Keyboard.KeyIsPressed(GertKeys.RightArrow))
        _point.X += step * timestep;
      if (Input.Keyboard.KeyIsPressed(GertKeys.UpArrow))
        _point.Y -= step * timestep;
      if (Input.Keyboard.KeyIsPressed(GertKeys.DownArrow))
        _point.Y += step * timestep;

      _closest = _circle.ClosestPoint(_point);
    }

    protected override void Render()
    {
      Renderer.Clear(GertColor.Navy);
      Renderer.Begin();

      Renderer.ForegroundColor = GertColor.White;
      Renderer.DrawCircle(_circle);

      Renderer.ForegroundColor = GertColor.Green;
      Renderer.DrawPoint(_point);

      Renderer.ForegroundColor = GertColor.Red;
      Renderer.DrawPoint(_closest);

      Renderer.End();
    }

  }
}
